package main

import (
	"fmt"
	"math"
)

//salt值用来微调，防止随机串被预测
func pseudoEncrypt8(val int32, salt int32) int32 {
	if salt == 0 {
		salt = 150889
	}
	var l1 int32 = (val >> 13) & 8191
	var r1 int32 = val & 8191
	var l2, r2 int32
	var i int

	for i = 0; i < 3; i++ {
		l2 = r1
		r2 = l1 ^ int32(math.Round(float64((1366*r1+salt)%714025)/714025.0*8191))
		l1 = l2
		r1 = r2
	}

	return ((r1 << 13) + l1)
}

func main() {
	fmt.Println(pseudoEncrypt8(-3, 4))
}
